<template>
  <div class="header_content">
    <div>
      <img src="../../../assets/logo.png" alt="" />
      <h4>后台管理系统</h4>
    </div>
    <el-button class="btn" type="info" @click="logout">退出登录</el-button>
  </div>
</template>

<script>
export default {
  methods: {
    logout() {
      this.$confirm('此操作将退出登录, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          // 清除token
          window.sessionStorage.clear();
          this.$router.replace('/login');
          this.$message({
            type: 'success',
            message: '退出成功!',
          });
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消退出',
          });
        });
    },
  },
};
</script>

<style lang='less' scoped>
.header_content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #fff;
  > div {
    display: flex;
    align-items: center;
    img {
      width: 50px;
      height: 50px;
    }
    h4 {
      margin-left: 15px;
    }
  }
  .btn {
    margin-top: 10px;
  }
}
</style>
